#@bootStrapLayout("商户管理信息界面-外卖配送管理")

#define bootStrapMain()
<div class="container">
    #include("../../common/header.html")
    <div class="col-md-12">
        <ol class="breadcrumb">
            <li><a href="#">主页</a></li>
            <li class="active">外卖配送管理</li>
            <li></li>
        </ol>
        <div class="alert alert-success" role="alert">
            <!--温馨提示：当前页面将在<span id="refreshTime">60</span>秒以后自动刷新-->
            <!--<button id="stopButton">点我停止自动刷新</button>-->
            温馨提示:点击刷新按钮，查看最新派送状态
            <button id="refresh" type="button" class="btn btn-success">刷新</button>
        </div>
        <a href="/travel/foodDistribute/add" class="btn btn-primary">+添加</a>
    </div>
    <div class="col-md-12">
        <div style="text-align: center;margin:15px;">
            <form class="form-inline">
                <div class="form-group">
                    <label for="title">外卖订货人手机：</label>
                    <input type="text" class="form-control" id="mobile" placeholder="请输入手机号...">
                </div>
                <button type="button" id="searchBtn" class="btn btn-default">点我检索</button>
            </form>
        </div>
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>ID</th>
                <th>外卖订货人</th>
                <th>外卖订货人电话</th>
                <th>外卖点餐内容</th>
                <th>外卖送货地址</th>
                <th>外卖送货人</th>
                <th>状态</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody id="content">
            </tbody>
        </table>
        <div style="text-align: center" >
            <ul class="pagination" id="pagantion">

            </ul>
        </div>
    </div>
</div>
#end

#define bootStrapJs()

<script type="text/x-mustache" id="template">
     {{#items.list}}
            <tr id="item-{{id}}">
                <td>{{id}}</td>
                 <td>{{name}}</td>
                 <td>{{mobile}}</td>
                <td>{{item}}</td>
                <td>{{address}}</td>
                <td>{{sender}}</td>
                <td>{{status}}</td>
                <td>{{create_time}}</td>
                <td>
                    <a href="javascript:;" class="delete-btn" data-id="{{id}}">删除</a>|
                    <a href="javascript:;" class="edit-btn" data-id="{{id}}">编辑</a>|
                </td>
            </tr>
    {{/items.list}}
</script>

<script>
    $(document).ready(function(){
        // var refreshTime = 10;
        // var time = refreshTime;
        // var isStop=true;


        // function refresh(){
        //     time  = time -1;
        //     if(time>0){
        //         $("#refreshTime").html(time);
        //     }else{
        //         time = refreshTime;
        //         window.location.reload();
        //     }
        // }
        //
        // var timer = setInterval(refresh,1000);
        // $("#stopButton").click(function(){
        //     if(!isStop){
        //         isStop=true;
        //         clearInterval(timer)
        //         time =refreshTime;
        //         $("#stopButton").html("点我开启自动刷新");
        //         $("#refreshTime").html(refreshTime);
        //     }else{
        //         isStop=!isStop;
        //         $("#stopButton").html("点我停止自动刷新");
        //         timer = setInterval(refresh,1000);
        //     }
        // });

        $("#refresh").click(function(){
            window.location.reload();
        });

        $("#searchBtn").click(function(){
            initData();
        });

        initData();

        function initData(){
            var setting = {
                "url":"#(contextPath)/travel/foodDistribute/listAll",
                "data":{
                    "foodDistribute.mobile":$("#mobile").val(),

                },
            }
            var page = new Pagenation(setting);
            page.init();
        }

        $("#content").on("click",".delete-btn",function(){
            var id = $(this).attr("data-id");
            layer.confirm('确定要进行当前操作？', {
                btn: ['确定','取消']
            }, function(){
                $.ajax({
                    url:"/travel/foodDistribute/doDelete",
                    data:{id:id},
                    method:"post",
                    success:function(resp){
                        if(resp.result){
                            layer.msg(resp.data);
                            $("#item-"+id).remove();
                        }else{
                            layer.msg(resp.data);
                        }
                    }
                })
            }, function(){

            });
        });

        $("#content").on("click",".edit-btn",function(){
            var id = $(this).attr("data-id");
            layer.confirm('确定要进行当前操作？', {
                btn: ['确定','取消']
            }, function(){
                window.location.href="/travel/foodDistribute/queryById?id="+id
            }, function(){

            });
        });


    })
</script>
#end